package cn.wolfcode.education.query;

import cn.wolfcode.education.util.DateUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 每日任务高级查询
 */
@Getter@Setter
public class DayWorkQuery extends QueryObject {
    private String keyword;
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private Date workTime;

    /**
     * 需要封装普通必须的条件
     */
    private List<Long> deptIds = new ArrayList<>();
    private Long employeeId;

    public Date getEndTime(){
        //判断work是否为空
        if (workTime != null){
            return workTime != null ? DateUtil.getEndDate(workTime) : null;
        }
        return DateUtil.getEndDate(new Date());
    }
    /*//获取前一天的最后一秒
    public Date getBeginTime(){
        Date now = workTime;
        //判断work是否为空
        if (now != null){
            return now != null ? DateUtil.getBeginDate(now) : null;
        }
        return DateUtil.getBeginDate(new Date());
    }*/
    public String getKeyword(){
        return StringUtils.hasLength(keyword) ? keyword : null;
    }
}
